package com.yanqu.road.server.cmd.pageant;

import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.pb.pageant.PageantProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.activity.game2048.PageantModule;
import com.yanqu.road.server.manger.activity.NormalActivityMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Protocol;


@Cmd(code = Protocol.S_PAGEANT_NOTIFY_CONSUME_GOODS,desc = "通知使用选美大会活动道具")
public class PageantNotifyConsumeGoodsCmd extends AbstractCommand {

    private int activityId;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        PageantProto.PageantNotifyConsumeGoodsReqMsg reqMsg = PageantProto.PageantNotifyConsumeGoodsReqMsg.parseFrom(packet.getBytes());
        activityId = reqMsg.getActivityId();
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        ActivityInfo activityInfo = NormalActivityMgr.getActivityInfo(activityId);
        if(null != activityInfo) {
            player.getModule(PageantModule.class).autoUseActivityGoods(activityInfo);
        }
    }

    @Override
    public void sendData(GamePlayer player) {

    }
}
